package com.docking.heylo.web.controller;

import com.docking.heylo.constant.SystemConstant;
import com.docking.heylo.dao.entity.Evaluate;
import com.docking.heylo.service.IEvaluateService;
import com.docking.heylo.utils.HeyloMessageSource;
import com.docking.heylo.web.dto.EvaluteListDto;
import com.docking.heylo.web.utils.ResultUtil;
import com.docking.heylo.web.vo.BaseVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/***
 * 评价
 */
@RestController
@RequestMapping("/evaluate")
public class EvaluateController {

    @Autowired
    private HeyloMessageSource ms;

    @Autowired
    private IEvaluateService evaluateService;

    /***
     * 发布评价
     *
     * @return
     */
    @PostMapping("/pushEvaluate")
    public BaseVo pushEvaluate(@RequestBody Evaluate evaluate){
        evaluateService.pushEvaluate(evaluate );
        return ResultUtil.success(ms.getMessage(SystemConstant.success));
    }

    /***
     * 查看某个人的评论
     *
     * @return
     */
    @PostMapping("/evaluateForUser")
    public BaseVo evaluateForUser(@RequestBody EvaluteListDto evaluteListDto){
        PageInfo<Map<String,Object>> evaluates = evaluateService.evaluateForUser(evaluteListDto);
        return ResultUtil.success(ms.getMessage(SystemConstant.success), evaluates);
    }
















}
